Load all required libraries.

library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5     v purrr   0.3.4
## v tibble  3.1.3     v dplyr   1.0.7
## v tidyr   1.1.3     v stringr 1.4.0
## v readr   2.0.0     v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(broom)

Read in raw data from RDS.

raw_data <- readRDS("./year2.RDS")

Make a few small modifications to names and data for visualizations.

final_data <- raw_data %>% mutate(log_copy_per_L = log10(mean_copy_num_L)) %>%
  rename(Facility = wrf) %>%
  mutate(Facility = recode(Facility, 
                           "NO" = "WRF A",
                           "MI" = "WRF B",
                           "CC" = "WRF C"))

Seperate the data by gene target to ease layering in the final plot

#make three data layers
only_positives <<- subset(final_data, (!is.na(final_data$Facility)))
only_n1 <- subset(only_positives, target == "N1")
only_n2 <- subset(only_positives, target == "N2")
only_background <<-final_data %>% 
  select(c(date, cases_cum_clarke, new_cases_clarke, X7_day_ave_clarke)) %>%
  group_by(date) %>% summarise_if(is.numeric, mean)

#specify fun colors
background_color <- "#7570B3"
seven_day_ave_color <- "#E6AB02"
marker_colors <- c("N1" = '#1B9E77',"N2" ='#D95F02')
#remove facilty C for now
#only_n1 <- only_n1[!(only_n1$Facility == "WRF C"),]
#only_n2 <- only_n2[!(only_n2$Facility == "WRF C"),]

only_n1 <- only_n1[!(only_n1$Facility == "WRF A" & only_n1$date == "2020-11-02"), ]
only_n2 <- only_n2[!(only_n2$Facility == "WRF A" & only_n2$date == "2020-11-02"), ]

Build the main plot

      #first layer is the background epidemic curve
        p1 <- only_background %>%
              plotly::plot_ly() %>%
              plotly::add_trace(x = ~date, y = ~new_cases_clarke, 
                                type = "bar", 
                                hoverinfo = "text",
                                text = ~paste('</br> Date: ', date,
                                                     '</br> Daily Cases: ', new_cases_clarke),
                                alpha = 0.5,
                                name = "Daily Reported Cases",
                                color = background_color,
                                colors = background_color,
                                showlegend = FALSE) %>%
            layout(yaxis = list(title = "Clarke County Daily Cases", showline=TRUE)) %>%
            layout(legend = list(orientation = "h", x = 0.2, y = -0.3))
        
        #renders the main plot layer two as seven day moving average
        p1 <- p1 %>% plotly::add_trace(x = ~date, y = ~X7_day_ave_clarke, 
                             type = "scatter",
                             mode = "lines",
                             hoverinfo = "text",
                            text = ~paste('</br> Date: ', date,
                                                     '</br> Seven-Day Moving Average: ', X7_day_ave_clarke),
                             name = "Seven Day Moving Average Athens",
                             line = list(color = seven_day_ave_color),
                             showlegend = FALSE)
      

        
        #renders the main plot layer three as positive target hits
        
        p2 <- plotly::plot_ly() %>%
          plotly::add_trace(x = ~date, y = ~mean_copy_num_L,
                                       type = "scatter",
                                       mode = "markers",
                                       hoverinfo = "text",
                                       text = ~paste('</br> Date: ', date,
                                                     '</br> Facility: ', Facility,
                                                     '</br> Target: ', target,
                                                     '</br> Copies/L: ', round(mean_copy_num_L, digits = 2)),
                                       data = only_n1,
                                       symbol = ~Facility,
                                       marker = list(color = '#1B9E77', size = 8, opacity = 0.65),
                                       showlegend = FALSE) %>%
          plotly::add_trace(x = ~date, y = ~mean_copy_num_L,
                                       type = "scatter",
                                       mode = "markers",
                                       hoverinfo = "text",
                                       text = ~paste('</br> Date: ', date,
                                                     '</br> Facility: ', Facility,
                                                     '</br> Target: ', target,
                                                     '</br> Copies/L: ', round(mean_copy_num_L, digits = 2)),
                                       data = only_n2,
                                       symbol = ~Facility,
                                       marker = list(color = '#D95F02', size = 8, opacity = 0.65),
                                       showlegend = FALSE) %>%
            layout(yaxis = list(title = "SARS CoV-2 Copies/L", 
                                 showline = TRUE,
                                 type = "log",
                                 dtick = 1,
                                 automargin = TRUE)) %>%
            layout(legend = list(orientation = "h", x = 0.2, y = -0.3))
        
        #adds the limit of detection dashed line
        p2 <- p2 %>% plotly::add_segments(x = as.Date("2021-06-30"), 
                                          xend = ~max(date + 10), 
                                          y = 3571.429, yend = 3571.429,
                                          opacity = 0.35,
                                          line = list(color = "black", dash = "dash")) %>%
          layout(annotations = list(x = as.Date("2021-06-30"), y = 3.8, xref = "x", yref = "y", 
                                    text = "Limit of Detection", showarrow = FALSE))

        

        p1
        p2

Combine the two main plot pieces as a subplot

#seperate n1 and n2 frames by site
#n1
wrf_a_only_n1 <- subset(only_n1, Facility == "WRF A")
wrf_b_only_n1 <- subset(only_n1, Facility == "WRF B")
wrf_c_only_n1 <- subset(only_n1, Facility == "WRF C")

#n2
wrf_a_only_n2 <- subset(only_n2, Facility == "WRF A")
wrf_b_only_n2 <- subset(only_n2, Facility == "WRF B")
wrf_c_only_n2 <- subset(only_n2, Facility == "WRF C")


#rejoin the old data frames then seperate in to averages for each plant. 
wrfa_both <- full_join(wrf_a_only_n1, wrf_a_only_n2)%>%
  select(c(date, mean_total_copies)) %>%
  group_by(date) %>%
  summarize_if(is.numeric, mean) %>%
  ungroup() %>%
  mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke", "X7_day_ave_clarke", "Facility", "collection_num", "target", "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "mean_total_copies", "sd_total_copies", "log_copy_per_L")
wrfb_both <- full_join(wrf_b_only_n1, wrf_b_only_n2)%>%
  select(c(date, mean_total_copies)) %>%
  group_by(date) %>%
  summarize_if(is.numeric, mean) %>%
  ungroup() %>%
  mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke", "X7_day_ave_clarke", "Facility", "collection_num", "target", "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "mean_total_copies", "sd_total_copies", "log_copy_per_L")
wrfc_both <- full_join(wrf_c_only_n1, wrf_c_only_n2)%>%
  select(c(date, mean_total_copies)) %>%
  group_by(date) %>%
  summarize_if(is.numeric, mean) %>%
  ungroup() %>%
  mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke", "X7_day_ave_clarke", "Facility", "collection_num", "target", "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "mean_total_copies", "sd_total_copies", "log_copy_per_L")
#get max date
maxdate <- max(wrfa_both$date)
mindate <- min(wrfa_both$date)

Build loess smoothing figures figures

This makes the individual plots

#**************************************WRF A PLOT**********************************************
#add trendlines 
#extract data from geom_smooth
#both extract
# *********************************span 0.6***********************************
#*****************Must always update the n = TOTAL NUMBER OF DAYS*************************
extract_botha <- ggplot(wrfa_both, aes(x = date, y = log_total_copies_both)) + 
  stat_smooth(aes(outfit=fit_botha<<-..y..), method = "loess", color = '#1B9E77', 
              span = 0.3, n = 211)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_botha
## `geom_smooth()` using formula 'y ~ x'

fit_botha
##   [1] 11.53288 11.57123 11.60926 11.64697 11.68438 11.72151 11.75834 11.79485
##   [9] 11.83100 11.86679 11.90226 11.93742 11.97228 12.00688 12.04123 12.07536
##  [17] 12.10926 12.14291 12.17626 12.20929 12.24196 12.27423 12.30632 12.33836
##  [25] 12.37022 12.40176 12.43286 12.46336 12.49315 12.52092 12.54610 12.56959
##  [33] 12.59233 12.61524 12.63924 12.66524 12.69323 12.72223 12.75171 12.78118
##  [41] 12.81012 12.83802 12.86437 12.89091 12.91931 12.94895 12.97920 13.00943
##  [49] 13.03903 13.06736 13.09381 13.11774 13.13853 13.15557 13.16822 13.17877
##  [57] 13.18939 13.19922 13.20742 13.21312 13.21549 13.21368 13.20671 13.19479
##  [65] 13.17878 13.15958 13.13806 13.11511 13.09160 13.06842 13.04232 13.01049
##  [73] 12.97452 12.93597 12.89643 12.85746 12.82064 12.78754 12.75464 12.71828
##  [81] 12.67984 12.64067 12.60217 12.56569 12.53260 12.49830 12.45898 12.41717
##  [89] 12.37544 12.33633 12.30240 12.27620 12.25691 12.24168 12.22995 12.22120
##  [97] 12.21488 12.21045 12.20738 12.20512 12.20314 12.20089 12.19784 12.19345
## [105] 12.18963 12.18815 12.18820 12.18900 12.18975 12.18968 12.18799 12.18475
## [113] 12.18082 12.17661 12.17253 12.16898 12.16638 12.16512 12.16394 12.16163
## [121] 12.15868 12.15558 12.15282 12.15089 12.15030 12.15153 12.15507 12.16125
## [129] 12.16964 12.17960 12.19046 12.20157 12.21230 12.22198 12.23496 12.25425
## [137] 12.27722 12.30122 12.32362 12.34179 12.35307 12.35780 12.35845 12.35567
## [145] 12.35006 12.34227 12.33292 12.32263 12.31203 12.30176 12.29243 12.28468
## [153] 12.27913 12.27641 12.27715 12.27546 12.26721 12.25569 12.24417 12.23591
## [161] 12.23419 12.24229 12.25747 12.27468 12.29367 12.31423 12.33611 12.35908
## [169] 12.38291 12.41108 12.44657 12.48839 12.53557 12.58712 12.64206 12.69940
## [177] 12.75817 12.81737 12.87603 12.93317 12.98779 13.03893 13.08559 13.12679
## [185] 13.16155 13.18889 13.20782 13.21736 13.22207 13.22633 13.22888 13.22847
## [193] 13.22385 13.21378 13.19700 13.17522 13.15069 13.12297 13.09163 13.05622
## [201] 13.01633 12.97150 12.92180 12.86766 12.80916 12.74640 12.67947 12.60845
## [209] 12.53345 12.45456 12.37186
#assign fits to a vector
both_trenda <- fit_botha

#extract y min and max for each
limits_botha <- ggplot_build(extract_botha)$data
## `geom_smooth()` using formula 'y ~ x'
limits_botha <- as.data.frame(limits_botha)
both_ymina <- limits_botha$ymin
both_ymaxa <- limits_botha$ymax

#reassign dataframes (just to be safe)
work_botha <- wrfa_both

#fill in missing dates to smooth fits
work_botha <- work_botha %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_botha <- work_botha$date

#create a new smooth dataframe to layer
smooth_frame_botha <- data.frame(date_vec_botha, both_trenda, both_ymina, both_ymaxa)
#WRF A
#plot smooth frames
p_wrf_a <- plotly::plot_ly() %>%
  plotly::add_lines(x = ~date_vec_botha, y = ~both_trenda,
                    data = smooth_frame_botha,
                    hoverinfo = "text",
                    text = ~paste('</br> Date: ', date_vec_botha,
                                  '</br> Median Log Copies: ', round(both_trenda, digits = 2)),
                    line = list(color = '#1B9E77', size = 8, opacity = 0.65),
                    showlegend = FALSE) %>%
     layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_botha, ymin = ~both_ymina, ymax = ~both_ymaxa,
                    showlegend = FALSE,
                    opacity = 0.25,
                    hoverinfo = "text",
                    text = ~paste('</br> Date: ', date_vec_botha, #leaving in case we want to change
                                  '</br> Max Log Copies: ', round(both_ymaxa, digits = 2),
                                  '</br> Min Log Copies: ', round(both_ymina, digits = 2)),
                    name = "",
                    fillcolor = '#1B9E77',
                    line = list(color = '#1B9E77')) %>%
                layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies", 
                                 showline = TRUE,
                                 automargin = TRUE)) %>%
                layout(xaxis = list(title = "Date")) %>%
                layout(title = "WRF A") %>%
  plotly::add_markers(x = ~date, y = ~log_total_copies_both,
                      data = wrfa_both,
                       hoverinfo = "text",
                       showlegend = FALSE,
                       text = ~paste('</br> Date: ', date, 
                                     '</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
                       marker = list(color = '#1B9E77', size = 6, opacity = 0.65))

p_wrf_a
save(p_wrf_a, file = "./site_objects/wrf_a_year2.rda")
#**************************************WRF B PLOT**********************************************
#add trendlines 
#extract data from geom_smooth
#both extract
# *********************************span 0.6***********************************
#*****************Must always update the n = TOTAL NUMBER OF DAYS*************************
extract_bothb <- ggplot(wrfb_both, aes(x = date, y = log_total_copies_both)) + 
  stat_smooth(aes(outfit=fit_bothb<<-..y..), method = "loess", color = '#D95F02', 
              span = 0.3, n = 211)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_bothb
## `geom_smooth()` using formula 'y ~ x'

fit_bothb
##   [1] 10.68637 10.78306 10.87759 10.97003 11.06044 11.14887 11.23539 11.32000
##   [9] 11.40262 11.48321 11.56172 11.63811 11.71234 11.78436 11.85413 11.92167
##  [17] 11.98700 12.05016 12.11114 12.16995 12.22662 12.28115 12.33332 12.38302
##  [25] 12.43040 12.47563 12.51886 12.56025 12.59995 12.63814 12.67479 12.70974
##  [33] 12.74286 12.77399 12.80298 12.82970 12.85153 12.86716 12.87833 12.88679
##  [41] 12.89429 12.90258 12.91341 12.92560 12.93681 12.94706 12.95637 12.96477
##  [49] 12.97228 12.97892 12.98472 12.98969 12.99386 12.99725 12.99988 13.00133
##  [57] 13.00133 13.00010 12.99789 12.99492 12.99144 12.98767 12.98128 12.97067
##  [65] 12.95718 12.94215 12.92693 12.91286 12.90129 12.89356 12.88951 12.88758
##  [73] 12.88697 12.88692 12.88663 12.88533 12.88223 12.87655 12.87159 12.86999
##  [81] 12.87000 12.86989 12.86791 12.86230 12.85133 12.83571 12.81766 12.79773
##  [89] 12.77646 12.75441 12.73211 12.71010 12.68703 12.66147 12.63385 12.60464
##  [97] 12.57425 12.54315 12.51176 12.48055 12.44994 12.42038 12.39232 12.36619
## [105] 12.34481 12.32899 12.31618 12.30387 12.28949 12.27053 12.24444 12.20919
## [113] 12.16647 12.11934 12.07085 12.02405 11.98199 11.94773 11.91160 11.86466
## [121] 11.81103 11.75486 11.70025 11.65135 11.61228 11.58717 11.58015 11.58897
## [129] 11.60703 11.63185 11.66098 11.69198 11.72238 11.74973 11.78800 11.84750
## [137] 11.92030 11.99848 12.07411 12.13927 12.18604 12.22068 12.25467 12.28795
## [145] 12.32042 12.35202 12.38267 12.41227 12.44077 12.46807 12.49410 12.51877
## [153] 12.54202 12.56376 12.58391 12.59627 12.59763 12.59236 12.58486 12.57952
## [161] 12.58072 12.59286 12.61030 12.62524 12.63878 12.65202 12.66608 12.68206
## [169] 12.70105 12.72397 12.75066 12.78058 12.81323 12.84810 12.88465 12.92238
## [177] 12.96076 12.99929 13.03743 13.07469 13.11053 13.14445 13.17592 13.20443
## [185] 13.22946 13.25050 13.26702 13.27851 13.28674 13.29372 13.29929 13.30332
## [193] 13.30566 13.30614 13.30462 13.30131 13.29647 13.29005 13.28198 13.27222
## [201] 13.26070 13.24739 13.23230 13.21551 13.19703 13.17687 13.15504 13.13155
## [209] 13.10642 13.07965 13.05125
#assign fits to a vector
both_trendb <- fit_bothb

#extract y min and max for each
limits_bothb <- ggplot_build(extract_bothb)$data
## `geom_smooth()` using formula 'y ~ x'
limits_bothb <- as.data.frame(limits_bothb)
both_yminb <- limits_bothb$ymin
both_ymaxb <- limits_bothb$ymax

#reassign dataframes (just to be safe)
work_bothb <- wrfb_both

#fill in missing dates to smooth fits
work_bothb <- work_bothb %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_bothb <- work_bothb$date

#create a new smooth dataframe to layer
smooth_frame_bothb <- data.frame(date_vec_bothb, both_trendb, both_yminb, both_ymaxb)
#WRF B
#plot smooth frames
p_wrf_b <- plotly::plot_ly() %>%
  plotly::add_lines(x = ~date_vec_bothb, y = ~both_trendb,
                    data = smooth_frame_bothb,
                    hoverinfo = "text",
                    text = ~paste('</br> Date: ', date_vec_bothb,
                                  '</br> Median Log Copies: ', round(both_trendb, digits = 2)),
                    line = list(color = '#D95F02', size = 8, opacity = 0.65),
                    showlegend = FALSE) %>%
     layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_bothb, ymin = ~both_yminb, ymax = ~both_ymaxb,
                    showlegend = FALSE,
                    opacity = 0.25,
                    hoverinfo = "text",
                    text = ~paste('</br> Date: ', date_vec_bothb, #leaving in case we want to change
                                  '</br> Max Log Copies: ', round(both_ymaxb, digits = 2),
                                  '</br> Min Log Copies: ', round(both_yminb, digits = 2)),
                    name = "",
                    fillcolor = '#D95F02',
                    line = list(color = '#D95F02')) %>%
                layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies", 
                                 showline = TRUE,
                                 automargin = TRUE)) %>%
                layout(xaxis = list(title = "Date")) %>%
                layout(title = "WRF B") %>%
  plotly::add_markers(x = ~date, y = ~log_total_copies_both,
                      data = wrfb_both,
                       hoverinfo = "text",
                       showlegend = FALSE,
                       text = ~paste('</br> Date: ', date, 
                                     '</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
                       marker = list(color = '#D95F02', size = 6, opacity = 0.65))

p_wrf_b
save(p_wrf_b, file = "./site_objects/wrf_b_year2.rda")

#**************************************WRF C PLOT********************************************** #add trendlines #extract data from geom_smooth # *********************************span 0.6*********************************** #*****************Must always update the n = TOTAL NUMBER OF DAYS*************************

extract_bothc <- ggplot(wrfc_both, aes(x = date, y = log_total_copies_both)) + 
  stat_smooth(aes(outfit=fit_bothc<<-..y..), method = "loess", color = '#E7298A', 
              span = 0.3, n = 211)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_bothc
## `geom_smooth()` using formula 'y ~ x'

fit_bothc
##   [1] 10.75724 10.83393 10.90889 10.98193 11.05287 11.12150 11.18766 11.25156
##   [9] 11.31356 11.37367 11.43188 11.48820 11.54262 11.59515 11.64577 11.69401
##  [17] 11.73958 11.78284 11.82413 11.86379 11.90217 11.93960 11.97387 12.00340
##  [25] 12.02944 12.05329 12.07622 12.09951 12.12444 12.14954 12.17282 12.19475
##  [33] 12.21578 12.23640 12.25704 12.27819 12.29942 12.32008 12.34034 12.36037
##  [41] 12.38032 12.40036 12.42064 12.44113 12.46154 12.48171 12.50147 12.52063
##  [49] 12.53902 12.55647 12.57281 12.58786 12.60144 12.61339 12.62352 12.63463
##  [57] 12.64858 12.66379 12.67866 12.69160 12.70105 12.70540 12.70548 12.70331
##  [65] 12.69913 12.69319 12.68574 12.67702 12.66726 12.65673 12.64208 12.62109
##  [73] 12.59563 12.56757 12.53879 12.51116 12.48656 12.46686 12.45125 12.43716
##  [81] 12.42383 12.41050 12.39638 12.38071 12.36272 12.34288 12.32231 12.30120
##  [89] 12.27977 12.25822 12.23675 12.21558 12.19328 12.16872 12.14255 12.11544
##  [97] 12.08803 12.06098 12.03495 12.01057 11.98851 11.96943 11.95397 11.94279
## [105] 11.93589 11.93222 11.93090 11.93102 11.93167 11.93195 11.93097 11.93426
## [113] 11.94584 11.96252 11.98113 11.99848 12.01140 12.01671 12.01743 12.01851
## [121] 12.01959 12.02030 12.02029 12.01920 12.01669 12.01239 12.00595 11.99136
## [129] 11.96592 11.93420 11.90077 11.87020 11.84706 11.83593 11.83624 11.84272
## [137] 11.85288 11.86425 11.87433 11.88064 11.88069 11.87527 11.86720 11.85705
## [145] 11.84541 11.83284 11.81991 11.80721 11.79530 11.78475 11.77615 11.77006
## [153] 11.76706 11.76772 11.77261 11.77883 11.78388 11.78889 11.79501 11.80339
## [161] 11.81518 11.83152 11.85074 11.87057 11.89128 11.91316 11.93647 11.96149
## [169] 11.98849 12.01952 12.05599 12.09723 12.14256 12.19131 12.24281 12.29637
## [177] 12.35133 12.40701 12.46274 12.51785 12.57165 12.62347 12.67265 12.71850
## [185] 12.76035 12.79753 12.82937 12.85518 12.87739 12.89864 12.91862 12.93703
## [193] 12.95354 12.96784 12.97963 12.98934 12.99754 13.00411 13.00892 13.01184
## [201] 13.01274 13.01150 13.00817 13.00289 12.99570 12.98663 12.97569 12.96292
## [209] 12.94834 12.93198 12.91386
#assign fits to a vector
both_trendc <- fit_bothc

#extract y min and max for each
limits_bothc <- ggplot_build(extract_bothc)$data
## `geom_smooth()` using formula 'y ~ x'
limits_bothc <- as.data.frame(limits_bothc)
both_yminc <- limits_bothc$ymin
both_ymaxc <- limits_bothc$ymax

#reassign dataframes (just to be safe)
work_bothc <- wrfc_both

#fill in missing dates to smooth fits
work_bothc <- work_bothc %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_bothc <- work_bothc$date

#create a new smooth dataframe to layer
smooth_frame_bothc <- data.frame(date_vec_bothc, both_trendc, both_yminc, both_ymaxc)
#WRF C
#plot smooth frames
p_wrf_c <- plotly::plot_ly() %>%
  plotly::add_lines(x = ~date_vec_bothc, y = ~both_trendc,
                    data = smooth_frame_bothc,
                    hoverinfo = "text",
                    text = ~paste('</br> Date: ', date_vec_bothc,
                                  '</br> Median Log Copies: ', round(both_trendc, digits = 2)),
                    line = list(color = '#E7298A', size = 8, opacity = 0.65),
                    showlegend = FALSE) %>%
     layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_bothc, ymin = ~both_yminc, ymax = ~both_ymaxc,
                    showlegend = FALSE,
                    opacity = 0.25,
                    hoverinfo = "text",
                    text = ~paste('</br> Date: ', date_vec_bothc, #leaving in case we want to change
                                  '</br> Max Log Copies: ', round(both_ymaxc, digits = 2),
                                  '</br> Min Log Copies: ', round(both_yminc, digits = 2)),
                    name = "",
                    fillcolor = '#E7298A',
                    line = list(color = '#E7298A')) %>%
                layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies", 
                                 showline = TRUE,
                                 automargin = TRUE)) %>%
                layout(xaxis = list(title = "Date")) %>%
                layout(title = "WRF C") %>%
  plotly::add_markers(x = ~date, y = ~log_total_copies_both,
                      data = wrfc_both,
                       hoverinfo = "text",
                       showlegend = FALSE,
                       text = ~paste('</br> Date: ', date, 
                                     '</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
                       marker = list(color = '#E7298A', size = 6, opacity = 0.65))

p_wrf_c
save(p_wrf_c, file = "./site_objects/wrf_c_year2.rda")

keeping in case

#save(wrfa_both, file = "./plotly_objs/wrfa_both.rda")
#save(wrfb_both, file = "./plotly_objs/wrfb_both.rda")
#save(wrfc_both, file = "./plotly_objs/wrfc_both.rda")
#save(date_vec_botha, file = "./plotly_objs/date_vec_botha.rda")
#save(date_vec_bothb, file = "./plotly_objs/date_vec_bothb.rda")
#save(date_vec_bothc, file = "./plotly_objs/date_vec_bothc.rda")
#save(both_ymina, file = "./plotly_objs/both_ymina.rda")
#save(both_ymaxa, file = "./plotly_objs/both_ymaxa.rda")

#save(both_yminb, file = "./plotly_objs/both_yminb.rda")
#save(both_ymaxb, file = "./plotly_objs/both_ymaxb.rda")

#save(both_yminc, file = "./plotly_objs/both_yminc.rda")
#save(both_ymaxc, file = "./plotly_objs/both_ymaxc.rda")